package main

import (
	"github.com/gin-gonic/gin"
	"k8s-platform/config"
	"k8s-platform/controller"
	"k8s-platform/db"
	"k8s-platform/model"
	"k8s-platform/service"
	"net/http"
)

func main()  {
	//读取配置文件
	config.GetConfig()
	db.Init()
	defer db.Close()

	model.MakeMigrate()
	//初始化gin
	r := gin.Default()

	//挎包调用router的初始化方法
	controller.Router.InitApiRouter(r)
	//初始化k8s client
	service.K8s.Init()

	go func() {
		http.HandleFunc("/ws",service.ContainerExec) //middle.Terminal.WsHandler
		http.ListenAndServe(":8082",nil)
		//ws://localhost:8082/ws?pod_name=busybox-7f55dfbb99-4s8dv&namespace=default&container_name=busybox
	}()
	r.Run(config.Port)

}